<template>
  <div class="home-shop-list">
    <BusinessItem  v-for="v in businessList" :data="v" />
  </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import {reqBusinessByType, reqBusInfo} from "@/api/home";
import type {BusinessInfo, BusinessResponseData} from "@/api/home/type.ts";
import BusinessItem from "@/views/Tabber/home/components/BusinessItem.vue";
interface IProps{
  type:number
}
const props=defineProps<IProps>();
//存储商家信息列表
let businessList=ref([]);
const getBusinessInfo=async()=>{
  let num=props.type;
  if(num==0||num==2){
    let result:BusinessResponseData=await reqBusInfo();
    console.log(result)
    if(result.code==1){
      businessList.value=result.data;
    }
  }else{
    let result:BusinessResponseData=await reqBusinessByType(num);
    if(result.code==1){
      businessList.value=result.data;
    }
  }
}
onMounted(()=>{
  getBusinessInfo();
})

//组件挂载时 发出请求
</script>

<style scoped>
.home-shop-list {
  padding: 8px 10px;
}
</style>